#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 练习一：在元类中控制把自定义类的数据属性都变成大写


class Myfoo(type):
    def __call__(self, *args, **kwargs):
        obj = self.__new__(self)                # 创建一个空对象
        self.__init__(obj, *args, **kwargs)     # 为该空对象初始化独有的属性
        obj.__dict__ = {"{}".format(k.upper()): v for k, v in obj.__dict__.items()}
        return obj


class Foo(object, metaclass=Myfoo):
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __new__(cls, *args, **kwargs):
        # print(cls)          # <class '__main__.Foo'>
        # print(args)         #
        # print(kwargs)
        return super(Foo, cls).__new__(cls)


f = Foo("xiong", "hhhh")
# print(f.__dict__)
print(f.__dict__)